package org.vox.homepage.infra

import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.context.annotation.Bean
import org.springframework.web.servlet.config.annotation.{InterceptorRegistry, WebMvcConfigurerAdapter}
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
import javax.servlet.Filter

/**
  * @author Borg.lee
  */
@Configuration
class Configuration extends WebMvcConfigurer {
//class Configuration extends WebMvcConfigurerAdapter {
  override def addInterceptors(registry: InterceptorRegistry): Unit = {
    registry.addInterceptor(new GeneralInterceptor())
  }

  @Bean
  def authFilter(): FilterRegistrationBean[Filter] = {
    val registration = new FilterRegistrationBean[Filter]()

    registration.setFilter(null)
    registration.addUrlPatterns("/*")
    registration.setName("authFilter")
    registration.setOrder(1)

    registration
  }
}
